<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page import="java.util.List" %>
<%@ page import="com.example.domain.Report" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>举报管理 - 论坛系统</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        body {
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
            background: linear-gradient(135deg, #f8fafc 0%, #e0f2fe 100%);
            min-height: 100vh;
            color: #374151;
        }

        .header {
            background: rgba(255, 255, 255, 0.95);
            backdrop-filter: blur(10px);
            box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
            border-bottom: 1px solid rgba(255, 255, 255, 0.2);
            position: sticky;
            top: 0;
            z-index: 100;
        }

        .header-content {
            max-width: 1200px;
            margin: 0 auto;
            padding: 20px;
            display: flex;
            justify-content: space-between;
            align-items: center;
            flex-wrap: wrap;
            gap: 16px;
        }

        .header h1 {
            font-size: 28px;
            font-weight: bold;
            background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
            background-clip: text;
            display: flex;
            align-items: center;
            gap: 12px;
        }

        .back-btn {
            background: linear-gradient(135deg, #6b7280 0%, #4b5563 100%);
            color: white;
            padding: 12px 24px;
            border: none;
            border-radius: 25px;
            text-decoration: none;
            font-weight: 600;
            transition: all 0.3s ease;
            display: flex;
            align-items: center;
            gap: 8px;
        }

        .back-btn:hover {
            transform: translateY(-2px);
            box-shadow: 0 8px 25px rgba(107, 114, 128, 0.4);
        }

        .container {
            max-width: 1200px;
            margin: 0 auto;
            padding: 30px 20px;
        }

        .table-container {
            background: rgba(255, 255, 255, 0.95);
            backdrop-filter: blur(10px);
            border-radius: 20px;
            box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
            overflow: hidden;
            border: 1px solid rgba(255, 255, 255, 0.2);
        }

        .table-header {
            background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
            color: white;
            padding: 30px;
            text-align: center;
        }

        .table-header h2 {
            font-size: 24px;
            font-weight: 700;
            margin-bottom: 8px;
        }

        .table-header p {
            opacity: 0.9;
            font-size: 16px;
        }

        .table-wrapper {
            overflow-x: auto;
        }

        table {
            width: 100%;
            border-collapse: collapse;
        }

        th, td {
            padding: 20px 16px;
            text-align: left;
            border-bottom: 1px solid rgba(229, 231, 235, 0.5);
        }

        th {
            background: rgba(248, 250, 252, 0.8);
            font-weight: 600;
            color: #374151;
            font-size: 14px;
            text-transform: uppercase;
            letter-spacing: 0.5px;
        }

        td {
            color: #4b5563;
            font-size: 15px;
        }

        tr:hover {
            background: rgba(248, 250, 252, 0.5);
        }

        .status-badge {
            padding: 8px 16px;
            border-radius: 20px;
            font-size: 12px;
            font-weight: 600;
            text-transform: uppercase;
            letter-spacing: 0.5px;
        }

        .status-pending {
            background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
            color: #92400e;
        }

        .status-processed {
            background: linear-gradient(135deg, #d1fae5 0%, #a7f3d0 100%);
            color: #065f46;
        }

        .status-rejected {
            background: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%);
            color: #991b1b;
        }

        .reason-text {
            max-width: 200px;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
            background: rgba(248, 250, 252, 0.5);
            padding: 8px 12px;
            border-radius: 8px;
            cursor: pointer;
            transition: all 0.3s ease;
        }

        .reason-text:hover {
            background: rgba(229, 231, 235, 0.5);
            white-space: normal;
            max-width: none;
        }

        .action-group {
            display: flex;
            flex-direction: column;
            gap: 8px;
        }

        .action-form {
            display: flex;
            align-items: center;
            gap: 8px;
            flex-wrap: wrap;
        }

        .action-select {
            padding: 8px 12px;
            border: 2px solid #e5e7eb;
            border-radius: 8px;
            font-size: 12px;
            background: white;
            transition: all 0.3s ease;
            min-width: 100px;
        }

        .action-select:focus {
            outline: none;
            border-color: #ef4444;
            box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
        }

        .action-btn {
            padding: 8px 12px;
            border: none;
            border-radius: 8px;
            font-size: 12px;
            font-weight: 600;
            cursor: pointer;
            transition: all 0.3s ease;
            display: inline-flex;
            align-items: center;
            gap: 4px;
        }

        .btn-update {
            background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
            color: white;
        }

        .btn-block-post {
            background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
            color: white;
        }

        .btn-block-comment {
            background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
            color: white;
        }

        .action-btn:hover {
            transform: translateY(-1px);
            box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
        }

        .empty-state {
            text-align: center;
            padding: 80px 20px;
            color: #6b7280;
        }

        .empty-state-icon {
            font-size: 64px;
            margin-bottom: 24px;
            opacity: 0.5;
        }

        .empty-state h3 {
            font-size: 24px;
            color: #374151;
            margin-bottom: 12px;
        }

        .empty-state p {
            font-size: 16px;
            line-height: 1.6;
        }

        .id-badge {
            background: linear-gradient(135deg, #f3f4f6 0%, #e5e7eb 100%);
            color: #374151;
            padding: 4px 8px;
            border-radius: 6px;
            font-size: 12px;
            font-weight: 600;
        }

        .priority-indicator {
            width: 8px;
            height: 8px;
            border-radius: 50%;
            display: inline-block;
            margin-right: 8px;
        }

        .priority-high {
            background: #ef4444;
            box-shadow: 0 0 8px rgba(239, 68, 68, 0.5);
        }

        .priority-medium {
            background: #f59e0b;
            box-shadow: 0 0 8px rgba(245, 158, 11, 0.5);
        }

        .priority-low {
            background: #10b981;
            box-shadow: 0 0 8px rgba(16, 185, 129, 0.5);
        }

        @media (max-width: 768px) {
            .header-content {
                flex-direction: column;
                text-align: center;
            }

            .reason-text {
                max-width: 150px;
            }

            .action-form {
                flex-direction: column;
                gap: 6px;
            }

            .action-select,
            .action-btn {
                width: 100%;
            }

            th, td {
                padding: 12px 8px;
                font-size: 13px;
            }
        }

        @media (max-width: 480px) {
            .container {
                padding: 20px 16px;
            }

            .table-header {
                padding: 20px;
            }

            .table-header h2 {
                font-size: 20px;
            }
        }
    </style>
</head>
<body>
<div class="header">
    <div class="header-content">
        <h1>
            <span>🚨</span>
            <span>举报管理</span>
        </h1>
        <a href="/admin" class="back-btn">
            <span>🏠</span>
            <span>返回管理首页</span>
        </a>
    </div>
</div>

<div class="container">
    <div class="table-container">
        <div class="table-header">
            <h2>待处理举报</h2>
            <p>及时处理用户举报，维护社区秩序</p>
        </div>

        <%
            List<Report> reports = (List<Report>) request.getAttribute("reports");
            if (reports != null && !reports.isEmpty()) {
        %>
        <div class="table-wrapper">
            <table>
                <thead>
                <tr>
                    <th>举报ID</th>
                    <th>帖子ID</th>
                    <th>评论ID</th>
                    <th>举报用户</th>
                    <th>举报原因</th>
                    <th>状态</th>
                    <th>操作</th>
                </tr>
                </thead>
                <tbody>
                <% for (Report r : reports) { %>
                <tr>
                    <td>
                        <span class="priority-indicator priority-<%= "pending".equals(r.getStatus()) ? "high" : "low" %>"></span>
                        <span class="id-badge"><%= r.getId() %></span>
                    </td>
                    <td>
                        <%= r.getPostId() == null ? "-" : "<span class='id-badge'>" + r.getPostId() + "</span>" %>
                    </td>
                    <td>
                        <%= r.getCommentId() == null ? "-" : "<span class='id-badge'>" + r.getCommentId() + "</span>" %>
                    </td>
                    <td><span class="id-badge"><%= r.getUserId() %></span></td>
                    <td>
                        <div class="reason-text" title="<%= r.getReason() %>">
                            <%= r.getReason() %>
                        </div>
                    </td>
                    <td>
                        <span class="status-badge status-<%= r.getStatus() %>">
                            <%
                                String statusText = "pending".equals(r.getStatus()) ? "待处理" :
                                        "processed".equals(r.getStatus()) ? "已处理" : "已拒绝";
                            %>
                            <%= statusText %>
                        </span>
                    </td>
                    <td>
                        <div class="action-group">
                            <form action="/admin/updateReport" method="post" class="action-form">
                                <input type="hidden" name="id" value="<%= r.getId() %>">
                                <select name="status" class="action-select">
                                    <option value="processed">已处理</option>
                                    <option value="rejected">已拒绝</option>
                                </select>
                                <button type="submit" class="action-btn btn-update">
                                    <span>✅</span>
                                    <span>更新</span>
                                </button>
                            </form>

                            <% if (r.getPostId() != null) { %>
                            <form action="/admin/blockPost" method="post" class="action-form">
                                <input type="hidden" name="id" value="<%= r.getPostId() %>">
                                <button type="submit" class="action-btn btn-block-post">
                                    <span>🚫</span>
                                    <span>屏蔽帖子</span>
                                </button>
                            </form>
                            <% } %>

                            <% if (r.getCommentId() != null) { %>
                            <form action="/admin/blockComment" method="post" class="action-form">
                                <input type="hidden" name="id" value="<%= r.getCommentId() %>">
                                <button type="submit" class="action-btn btn-block-comment">
                                    <span>🔇</span>
                                    <span>屏蔽评论</span>
                                </button>
                            </form>
                            <% } %>
                        </div>
                    </td>
                </tr>
                <% } %>
                </tbody>
            </table>
        </div>
        <% } else { %>
        <div class="empty-state">
            <div class="empty-state-icon">🎉</div>
            <h3>暂无举报记录</h3>
            <p>目前没有需要处理的举报，社区运行良好！</p>
        </div>
        <% } %>
    </div>
</div>
</body>
</html>
